/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019.
 * Description: support gpio lock
 * Author: zhoumansuo <zhoumansuo@huawei.com>
 * Create: 2018-09-13
 */

#include<linux/spinlock.h>
#include<linux/sched.h>

static DEFINE_SPINLOCK(rtos_gpio_spinlock);
static unsigned long flags;

inline void rtos_gpio_lock(void)
{
	spin_lock_irqsave(&rtos_gpio_spinlock, flags);
}
EXPORT_SYMBOL(rtos_gpio_lock);

inline void rtos_gpio_unlock(void)
{
	spin_unlock_irqrestore(&rtos_gpio_spinlock, flags);
}
EXPORT_SYMBOL(rtos_gpio_unlock);

/* export gpio spinlock */
void rtos_gpio_spinlock_init(void)
{
	if (raw_smp_processor_id() == 0)
		spin_lock_init(&rtos_gpio_spinlock);
}
